Range Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Returns a view onto a sub-range of a list. Items from list are not copied; the returned IList<T> is simply a different view onto the same underlying items. Changes to list are reflected in the view, and vice versa. Insertions and deletions in the view change the size of the view, but insertions and deletions in the underlying list do not.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static IList<T> Range<T>(
	IList<T> list,
	int start,
	int count
)
Visual Basic (Declaration)
Public Shared Function Range(Of T) ( _
	list As IList(Of T), _
	start As Integer, _
	count As Integer _
) As IList(Of T)
Visual C++
public:
generic<typename T>
static IList<T>^ Range (
	IList<T>^ list, 
	int start, 
	int count
)

Parameters

list
IList<(Of <T>)>
The list to view.
start
Int32
The starting index of the view.
count
Int32
The number of items in the view.

Return Value

A list that is a view onto the given sub-list.

Type Parameters

T
The type of the items in the list.

Remarks

This method can be used to apply an algorithm to a portion of a list. For example:
 Copy imageCopy Code
Algorithms.ReverseInPlace(Algorithms.Range(list, 3, 6))
will reverse the 6 items beginning at index 3.

Exceptions

ExceptionCondition
System..::ArgumentNullExceptionlist is null.
System..::ArgumentOutOfRangeExceptionstart or count is negative.
System..::ArgumentOutOfRangeExceptionstart + count is greater than the size of list.

See Also